﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ch01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_1_Click(object sender, EventArgs e)
        {
            string sums1 = this.txt_sum1.Text;
            string sums2 = this.txt_sum2.Text;

            if (string.IsNullOrEmpty(sums1) || string.IsNullOrEmpty(sums2))
            {
                MessageBox.Show("您输入的信息不完整！");
                this.txt_sum1.Focus();
                return;
            }
            else
            {
                double sum3 = 0.0;
                double sum1 = Double.Parse(this.txt_sum1.Text);
                double sum2 = Double.Parse(this.txt_sum2.Text);
                string str = this.cbo_1.Text;
                switch (str)
                {
                    case"+":
                        sum3 = sum1 + sum2;
                        break;
                    case "-":
                        sum3 = sum1 - sum2;
                        break;
                    case "*":
                        sum3 = sum1 * sum2;
                        break;
                    case "/":
                        sum3 = sum1 / sum2;
                        break;
                    default:
                        break;
                }
                txt_sum3.Text= sum3.ToString(); 
            }
        }

        private void cbo_1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void btn_2_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("您确定要退出吗？","提示信息！",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
            if (dr==DialogResult.Yes)
            {
                this.Close();
            }
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            this.pictureBox2.Visible = true;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            this.pictureBox2.Visible = false;
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Maximum = 500;//设置最大长度值
            progressBar1.Value = 0;//设置当前值
            progressBar1.Step = 1;//设置没次增长多少
                System.Threading.Thread.Sleep(50);//暂停1秒
                progressBar1.Value += progressBar1.Step;//让进度条增加一次
            
        }
    }
}
